package com.gegong.imr.client.tasks;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import lombok.Data;

import java.util.List;

@Data
public class CenterResponse {

    private int code;
    private String msg;
    private JSON data;


    public boolean isSuccessful() {
        return code == 1;
    }

    public <T> T getData(Class<T> tClass) {
        return data.toJavaObject(tClass);
    }

    public <T> List<T> getList(Class<T> tClass) {
        JSONArray jsonArray = (JSONArray) data;
        return jsonArray.toJavaList(tClass);
    }
}
